package com.lightboat.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lightboat.common.utils.DateUtils;
import com.lightboat.system.domain.CrmProductStockRecord;
import com.lightboat.system.mapper.CrmProductStockRecordMapper;
import com.lightboat.system.service.ICrmProductStockRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品库存记录Service业务层处理
 *
 * @author lightboat
 * @date 2025-09-12
 */
@Service
@RequiredArgsConstructor
public class CrmProductStockRecordServiceImpl extends ServiceImpl<CrmProductStockRecordMapper, CrmProductStockRecord> implements ICrmProductStockRecordService {

    private final CrmProductStockRecordMapper crmProductStockRecordMapper;

    /**
     * 查询商品库存记录
     *
     * @param id 商品库存记录主键
     * @return 商品库存记录
     */
    @Override
    public CrmProductStockRecord selectCrmProductStockRecordById(Long id)
    {
        return crmProductStockRecordMapper.selectById(id);
    }

    /**
     * 查询商品库存记录列表
     *
     * @param crmProductStockRecord 商品库存记录
     * @return 商品库存记录
     */
    @Override
    public List<CrmProductStockRecord> selectCrmProductStockRecordList(CrmProductStockRecord crmProductStockRecord)
    {
        return crmProductStockRecordMapper.selectCrmProductStockRecordList(crmProductStockRecord);
    }

    /**
     * 新增商品库存记录
     *
     * @param crmProductStockRecord 商品库存记录
     * @return 结果
     */
    @Override
    public int insertCrmProductStockRecord(CrmProductStockRecord crmProductStockRecord)
    {
        crmProductStockRecord.setCreateTime(DateUtils.getNowDate());
        return crmProductStockRecordMapper.insert(crmProductStockRecord);
    }

    /**
     * 修改商品库存记录
     *
     * @param crmProductStockRecord 商品库存记录
     * @return 结果
     */
    @Override
    public int updateCrmProductStockRecord(CrmProductStockRecord crmProductStockRecord)
    {
        crmProductStockRecord.setUpdateTime(DateUtils.getNowDate());
        return crmProductStockRecordMapper.updateById(crmProductStockRecord);
    }

    /**
     * 批量删除商品库存记录
     *
     * @param ids 需要删除的商品库存记录主键
     * @return 结果
     */
    @Override
    public int deleteCrmProductStockRecordByIds(Long[] ids)
    {
        return crmProductStockRecordMapper.deleteCrmProductStockRecordByIds(ids);
    }

    /**
     * 删除商品库存记录信息
     *
     * @param id 商品库存记录主键
     * @return 结果
     */
    @Override
    public int deleteCrmProductStockRecordById(Long id)
    {
        return crmProductStockRecordMapper.deleteCrmProductStockRecordById(id);
    }
}
